package org.fhawk.tinyspring.aop.proxy;

import java.util.List;

public class ProxyManaggerFactory {
    private static ProxyManager proxyManager = new ProxyManager();
    private static CglibProxyManager cglibProxyManager = new CglibProxyManager();

    private ProxyManaggerFactory() {
    }

    public static Object newInstance(Class<?> target, List<Class<? extends Proxy>> proxyList) {
        Object instance;
        if (target.getInterfaces().length > 0) {
            instance = proxyManager.newInstance(target, proxyList);
        } else {
            instance = cglibProxyManager.newInstance(target, proxyList);
        }
        return instance;
    }
}
